<?php
	/**
	 * 获取用户邮件列表列表
	 */
    class EmailList extends APIBase {
		
		public $tag = "EmailList";
    	public $isLogin = true;
		
		public function before() {
			$this->initCacheRedis();
			$this->initMysql();
			return true;
		}
		public function logic(){
			$playerID = $this->uid;
			$UserEmailList = $this->cache_redis->keys("hUserEmailList:$playerID:*");
			$result = array();
			if(!empty($UserEmailList)){
				$count = count($UserEmailList);
			    if ($count) {
				    for($i=0;$i<$count;$i++){ 
					    $list = $this->cache_redis->hGetAll("hUserEmailList:$playerID:".$i);              
                        if($list['uid']==$playerID && $list['readstatus']!=9){
							$msglist = $this->cache_redis->hGetAll("hmg:".$list['mid']);
						    $result[] = array('title'=>$msglist['title'],'id'=>$list['id'],'readstatus'=>$list['readstatus'],'receivestatus'=>$list['receivestatus']);
					    }			 
				    }
	            }
				if(!empty($result)){
					$this->returnData($result);
				}else{
					$this->returnError(301,"用户暂无邮件");
				}
				
			}else{
				$this->returnError(301,"用户暂无邮件");
			}
		}
        public function after() {
			$this->deinitCacheRedis();
		}
    }
?>
